package com.lgc.garylianglib.imgDeal.multipleUtiil;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;

import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumFile;
import com.yanzhenjie.album.api.widget.Widget;

import java.util.ArrayList;

/**
 * description: 多张照片选择],直接调用，这是异步 不能返回的，除非用接口回调
 * usemethod： 在grade 添加    implementation 'com.yanzhenjie:album:2.0.2'
 * autour: feijin.sh.l
 * date: 2017/12/26 9:50
 * update: 2017/12/26
 * version:
 */

public class MultiplePicture {

    private static ArrayList<AlbumFile> mAlbumFiles;

    /**
     *
     * @param context
     * @param multiplePhone 接口 回调返回的图片数组
     */
    public static void selectImage(Context context , final MultiplePhone multiplePhone) {

        Album.image(context)//异步的
                .multipleChoice()
                .requestCode(200)
                .camera(true)
                .columnCount(2)
                .selectCount(6)
                .checkedList(mAlbumFiles)
                .widget(
                        Widget.newDarkBuilder(context)
                                .title("hhhh")
                                .build()
                )
                .onResult(new Action<ArrayList<AlbumFile>>() {
                    @Override
                    public void onAction(int requestCode, @NonNull ArrayList<AlbumFile> result) {
                        mAlbumFiles = result;
                        multiplePhone.getPhoto(result);
                        Log.e("liao", result.size() + "");
//                        mAdapter.notifyDataSetChanged(mAlbumFiles);
//                        mTvMessage.setVisibility(result.size() > 0 ? View.VISIBLE : View.GONE);
                    }
                })
                .onCancel(new Action<String>() {
                    @Override
                    public void onAction(int requestCode, @NonNull String result) {

                    }
                })
                .start();

    }
}
